// 水路开关，具体实现为控制电磁阀

#ifndef _HEADER_Switch_H
#include "Switch.h"
#endif

Switch::Switch()
{

}

Switch::~Switch()
{
}

void Switch::setSwitchClass(SwitchClassEnum inClass)
{
    this->switchClass = inClass;
}

void Switch::setPort(int port)
{
    this->port = port;
    pinMode(port,OUTPUT);
}

void Switch::open()
{
    //电路控制
    digitalWrite(port,HIGH);
    //设置状态
    this->state = OPEN;
}
void Switch::close()
{
    //电路控制
    digitalWrite(port,LOW);
    //设置状态
    this->state = CLOSE;
}

void Switch::toString(char* inStr)
{
    sprintf(inStr,"Switch:{port=%d,state=%d}",port,state);
}
